<?php
if (!defined("IN_OP"))
{
    exit("You can't access this file directly...");
}
require_once( "class_3d/CheckMode_3d.php" );
$gametype = intval(getvar("gametype"));
$chkGametype = chkGametype($gametype);
$chk = new CheckMode_3d($curruser['acl'], 1, $gametype);
$chk->checkShow3dPage();
$show3D3S = $chk->show3D3S;
$show5N = getShow35($gametype);
$betname_3d = judge_type($gametype);
unset($chk);
$tbl = $g_gametype_3d[$gametype]['en'];
$tblName = $g_gametype_3d[$gametype]['ch'];
$curruser_p = user::getuser($curruser['id'], $gametype);
$ui = new UI_3D(true);
$tpl = new Template2();
$conf = new Config();
if ($curruser['acl'] != 255)
{
    $userlist = GetUserList($curruser['id']);
    if ($userlist == "")
    {
        $ui->showErrorPage("<p>还没有建立会员！</p>");
        exit();
    }
}
if ($chkGametype == 3)
{
    include_once( "class_5h/RateConfig_5h.php" );
    include_once( "class_5h/SRate_5h.php" );
    $RateConfig_3d = new RateConfig_5h($gametype);
    if (20 < $gametype)
    {
        $_5hFlag = false;
        $_8hFlag = true;
    }
    else
    {
        $_5hFlag = true;
        $_8hFlag = false;
    }
    $tempOrderArr = array();
}
elseif ($chkGametype == 4)
{
    include_once( "class_sb/RateConfig_sb.php" );
    include_once( "class_sb/SRate_sb.php" );
    $RateConfig_3d = new RateConfig_sb($gametype);
    $_5hFlag = false;
    $_8hFlag = false;	
	$tempOrderArr = array();
}
else
{
    include_once( "class_3d/RateConfig_3d.php" );
    include_once( "class_3d/SRate_3d.php" );
    $RateConfig_3d = new RateConfig_3d($gametype);
    $_5hFlag = false;
    $_8hFlag = false;
    $tempOrderArr = array("r1" => "r1", "r1p" => "r1p", "r2" => "r2", "nn" => "nn", "sh" => "sh");
}
switch ($show3D3S)
{
    case 0 :
        $SRate_3d = new SRate_3d($gametype);
        break;
    case 1 :
        $SRate_3d = new SRate_3s($gametype);
        break;
    case 2 :
        $SRate_3d = new SRate_5h($gametype);
        break;
	case 3 :
        $SRate_3d = new SRate_sb($gametype);
        break;
    default :
        exit("error show3d3s");
        break;
}
$u5id = $SRate_3d->getAcl5ID($curruser['id'], $curruser['acl']);
$u5 = get_user($u5id, $gametype);
if ($curruser['acl'] == "1" || $curruser['acl'] == "255")
{
    exit();
}
else if ($curruser['enabled'] == 0 || $curruser['enabled'] == 2)
{
    $ui->showErrorPage("{$tblName} :: 帐号已暂停");
    exit();
}
else if ($conf->get("protect_start_{$tbl}") != "1")
{
    $ui->showErrorPage("{$tblName} :: 系统走飞模式已关闭");
    exit();
}
else if ($u5['protmod'] != "1")
{
    $ui->showErrorPage("{$tblName} :: 管理层走飞已关闭" . $u5['protmod']);
    exit();
}
else if ($curruser['acl'] == 2 && $curruser_p['mpercent'] == 0)
{
    $ui->showErrorPage("{$tblName} :: 本身最大占成值为0,无法走飞");
    exit();
}
else if ($curruser['acl'] == 5 && $curruser_p['percent_sw'] == 1)
{
    $ui->showErrorPage("{$tblName} :: 你是固定占成的大股东,不能走飞");
    exit();
}
$u5_percent_sw = $u5['percent_sw'];
unset($u5);
$tbl = $g_gametype_3d[$gametype]['en'];
$tblName = $g_gametype_3d[$gametype]['ch'];
$pg = $g_gametype_3d[$gametype]['pg'];
$split = 1;
$disk = 0;
$order = 2;
$playtype = getvar("playtype");
$id = getvar("id");
$bid = getvar("bid");
$ratemod = 0;
if ($id == "")
{
    $showday = date("Y-m-d");
    $lottoData = $SRate_3d->getLotto3DByDate($showday);
}
else
{
    exit("error id");
    $id = intval($id);
    $lottoData = $SRate_3d->getLotto3DById($id);
    $showday = $lottoData['open'];
}
if ($lottoData == "")
{
    $ui->showErrorPage("目前没有{$tblName}可以下注期数！", true);
    exit();
}
$split = 1;
$playtype = isset($RateConfig_3d->playtypeArr02[$playtype]) ? $playtype : "r1";
if ($bid != "")
{
    $fieldsArr = array($bid);
}
else
{
    $fieldsArr = $RateConfig_3d->playGroupArr02[$playtype];
}
$bidstr = "";
if ($bid == "")
{
    $bidstr = "";
}
else
{
    $bid == intval($bid);
    if (!in_array($bid, $RateConfig_3d->playGroupArr02[$playtype]))
    {
        diemsg("{$tblName}玩法资料错误。");
    }
    $bidstr = "&bid=" . $bid;
    $tpl->set("bid", $bid);
}
$menu_list_url = "";
$tempUrl = "op.php?op=agent&fp=bnow_3d&gametype={$gametype}&playtype=";
$tempArr = array();
if ($show5N)
{
    $jsFuname = "_n5";
    $jsFunameFlag = "true";
}
else
{
    $jsFuname = "";
    $jsFunameFlag = "false";
}
if ($_5hFlag)
{
    $xyid = 1;
    $tempArr[] = "<th width='10%'>" . getOptionXYList($xyid, false, "", "xyid", "xyid") . "<span id='noxystr' class='noneRateRecord'>单一盘</span></th>";
}
else
{
    unset($RateConfig_3d->playtypeArr02['rcmp']);
}
foreach ($RateConfig_3d->playtypeArr02 as $key => $val)
{
    $showUrl = $tempUrl . $key;
    if ($playtype == $key)
    {
        $tempClass = " class=\"cbig\"";
    }
    else
    {
        $tempClass = "";
    }
    $tempArr[] = "<th {$tempClass} id='myThBar{$key}' ><a href=\"javascript:clickTitle('{$key}');\">{$val}</a><br />(<span style='color:#cc0000' id='spanPageAmount{$key}'></span>)</th>";
}
$menu_list_url = implode("", $tempArr);
switch ($show3D3S)
{
    case 0 :
        $stopbet_3d = $conf->get("stopbet_{$tbl}");
        if ($stopbet_3d == "0000")
        {
            $stopbet_3d = "2359";
        }
        $tempStrInt = false;
        break;
    case 1 :
    case 2 :
	case 3 :
        $tempStrInt = strtotime($lottoData['stopbet']);
        break;
}
if ($tempStrInt == false)
{
    $h = substr($stopbet_3d, 0, 2);
    $m = substr($stopbet_3d, 2);
    $tempStr = "{$showday} {$h}:{$m}:00";
    $timetamp = systime();
    $timetamplimit = strtotime($tempStr) - $timetamp;
}
else
{
    $timetamp = systime();
    $timetamplimit = $tempStrInt - $timetamp;
}
$disabledbet = "";
if ($timetamplimit < 1)
{
    $disabledbet = "disabled=\"disabled\"";
}
$tpl->load("main", "bnow_3d.htm");
$quickBtnDisplay = "";
if (isset($tempOrderArr[$playtype]))
{
    $order = 2;
}
$tpl->set(array("playtype" => $RateConfig_3d->playtypeArr02[$playtype], "menu_list_url" => $menu_list_url, "lotto_id_3d" => $lottoData['id'], "round" => d3($lottoData['round']), "open" => $lottoData['open'], "timetamp" => $timetamp, "timetamplimit" => $timetamplimit, "playtypestr" => $playtype, "split" => $split, "order" => $order, "disk" => $disk, "ratemod" => $ratemod, "gametype" => $gametype, "gametypeStr" => $tblName, "reloadCK" => "60", "jsLang" => $g_conf['language'], "jsFuname" => $jsFuname, "pg" => $pg, "subid" => $_5hFlag || $_8hFlag ? intval(getvar("subid")) : "0"));
$jslink = "<script src=\"js_3d/jquery-ui-1.8.11.custom.min.js\"></script>\n";
$jslink .= "<script src=\"js_3d/showRateRecord.js\"></script>\n";
$jslink .= "<script src=\"js_3d/js3d.js\"></script>\n";
$jslink .= "<script>";
$jslink .= "var __roundID = " . $lottoData['id'] . ";";
$jslink .= "var __reloadCK = 0;";
$jslink .= "var now = new Date(1000 * {$timetamp});";
$jslink .= "var timestap = {$timetamplimit};";
$jslink .= "var myGlobalVal = {};";
$jslink .= "myGlobalVal.gametype = '{$gametype}';";
$jslink .= "myGlobalVal.lotto_id_3d = " . $lottoData['id'] . ";";
$jslink .= "myGlobalVal.playtypestr = '{$playtype}';";
$jslink .= "myGlobalVal.open = '" . $lottoData['open'] . "';";
$jslink .= "myGlobalVal.reloadCK = '60';";
$jslink .= "myGlobalVal.jsFuname = {$jsFunameFlag};";
$jslink .= "var _playtype = 'r1';";
if ($_5hFlag || $_8hFlag)
{
    $jslink .= "var _myHeader = '<thead><tr class=\"bgClc_{$gametype}\"><th>类别1</th><th>合计</th><th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th></tr></thead>'; ";
    $jslink .= "var _myHeader2 = '<thead><tr class=\"td6\"><th>类别2</th><th>合计</th><th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th></tr></thead>'; ";
    $jslink .= "var _myHeader3 = '<thead><tr class=\"bgClc_{$gametype}\"><th>类别3</th><th>合计</th><th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th></tr></thead>'; ";
}
else
{
    $jslink .= "var _myHeader = '<thead><tr class=\"td0 bgClc_{$gametype}\"><th>类别</th><th>合计</th><th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th></tr></thead>';";
    $jslink .= "var _myHeader2 = '<thead><tr class=\"td6\"><th>类别</th><th>合计</th><th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th></tr></thead>';";
    $jslink .= "var _myHeader3 = '<thead><tr class=\"td0 bgClc_{$gametype}\"><th>类别</th><th>合计</th><th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th></tr></thead>';";
}
$jslink .= "var uMsg = new Array();";
$jslink .= "var uTitle = new Array();";
$jslink .= "uMsg[0] = '走飞完成！因更新资料需要时间,若画面未即时更新,请稍等一下,谢谢。';";
$jslink .= "uMsg[1] = '请输入赔率';";
$jslink .= "uMsg[2] = '请输入金额';";
$jslink .= "uMsg[3] = '请勾选号码';";
$jslink .= "uMsg[4] = '走飞内容';";
$jslink .= "uMsg[5] = '合计';";
$jslink .= "uMsg[6] = '笔';";
$jslink .= "uMsg[7] = '是否确定走飞?';";
foreach ($betname_3d as $key => $val)
{
    $jslink .= "uTitle['{$key}'] = '{$val}';";
}
$jslink .= "</script>";
$jsSrc = $_8hFlag?"8h":"";
if ( $gametype == 24 )
{
    $jsSrc = "pk10";
}
$jslink .= "<script src=\"scr{$pg}/" . $g_conf['language'] . "/bnow" . $jsSrc . ".js\"></script>\n";
$ui->set("jslink", $jslink);
$ui->header();
$tpl->show("main");
$ui->footer();
?>